/*********************************************************************************
 * 
 * Author: wujunjie
 * Create Date: 2014-05-10
 * Description:
 *          
 * Revision History:
 *      Date          Author               Description
 * 
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess;
using Xinkui.Entity.AutoGenerator;
using Xinkui.Common;
namespace Xinkui.DataAccess.AutoGenerator {
    public partial class CompanyCertificateMaintainDataAccess {
        public List<CompanyCertificateMaintain_Entity> CompanyCertificateMaintain_ListByPaging(int pageSize, int pageIndex, out int total) {
            total = 0;
            try {
                int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("CompanyCertificateMaintain_ListByPaging");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
                cmd.SetParameterValue("@RecordCount", tempRecord);
                List<CompanyCertificateMaintain_Entity> pageList = cmd.ExecuteEntityList<CompanyCertificateMaintain_Entity>();
                total = Convert.ToInt32(cmd.GetParameterValue("@RecordCount"));
                return pageList;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<CompanyCertificateMaintain_Entity>(0);

        }

        public CompanyCertificateMaintain_Entity CompanyCertificateMaintain_View(System.Int32 CertID) {
            CompanyCertificateMaintain_Entity c = default(CompanyCertificateMaintain_Entity);
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("CompanyCertificateMaintain_View");
                cmd.SetParameterValue("@CertID", CertID);
                c = cmd.ExecuteEntity<CompanyCertificateMaintain_Entity>();
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return c;
        }

        public CompanyCertificateMaintain_Entity CompanyCertificateMaintain_Add(CompanyCertificateMaintain_Entity entity) {
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("CompanyCertificateMaintain_Add");
                cmd.SetParameterValue("@CertID", entity.CertID);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@CertName", entity.CertName);
                cmd.SetParameterValue("@PicPath", entity.PicPath);
                cmd.SetParameterValue("@Remark", entity.Remark);
                cmd.SetParameterValue("@CreateDate", entity.CreateDate);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.SetParameterValue("@AuditStatus", entity.AuditStatus);
                cmd.SetParameterValue("@AuditDate", entity.AuditDate);
                cmd.SetParameterValue("@IsDeleted", entity.IsDeleted);
                cmd.ExecuteNonQuery();
                entity.CertID = (int)cmd.GetParameterValue("@CertID");
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return entity;
        }

        public bool CompanyCertificateMaintain_Update(CompanyCertificateMaintain_Entity entity) {
            bool succ = false;
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("CompanyCertificateMaintain_Update");
                cmd.SetParameterValue("@CertID", entity.CertID);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@CertName", entity.CertName);
                cmd.SetParameterValue("@PicPath", entity.PicPath);
                cmd.SetParameterValue("@Remark", entity.Remark);
                cmd.SetParameterValue("@CreateDate", entity.CreateDate);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.SetParameterValue("@AuditStatus", entity.AuditStatus);
                cmd.SetParameterValue("@AuditDate", entity.AuditDate);
                cmd.SetParameterValue("@IsDeleted", entity.IsDeleted);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

        public bool CompanyCertificateMaintain_Delete(System.Int32 CertID) {
            bool succ = false;
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("CompanyCertificateMaintain_Delete");
                cmd.SetParameterValue("@CertID", CertID);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

    }
}
